$(function(){
	//点击同居住地址调用
	$("input[name=same_juzhu]").each(function(){
		$(this).click(function() {
			if($(this).val()==1){
				$("#jsAddress_2").remove();
        		var $jsAddress_2=$('<div id="jsAddress_2"  class="selectbox_l"></div>')
        		$jsAddress_2.append('<input type="hidden" class="province" value="'+$("#jsAddress_0").find("input[name='province']").val()+'"/>'+
										'<input type="hidden" class="city" value="'+$("#jsAddress_0").find("input[name='city']").val()+'"/>'+
										'<input type="hidden" class="area" value="'+$("#jsAddress_0").find("input[name='area']").val()+'"/>'+
										'<div name="province" type="selectbox"  class="btn-group inline "></div>'+
										'<div name="city" type="selectbox"  class="btn-group inline"></div>'+
										'<div name="area" type="selectbox"  class="btn-group inline"></div>')
        		$jsAddress_2.ganged({'data': provinceList, 'width': 133, 'height': 32});
        		$jsAddress_2.prependTo($("#jsAddress_1").parent(".ml5"));
        		$("#jsAddress_1").hide();
        		if($("#juzhu_address1").val() !=null && $("#juzhu_address1").val() != "" && $("#juzhu_address1").val() != undefined){
        			$("#huji_address").val($("#juzhu_address1").val());
        		}else{
        			$("#huji_address").val($("#jsAddress_0").next().text().trim());
        		}
        	}else{
        		$("#jsAddress_2").remove();
        		$("#jsAddress_1").show();
        		$("#huji_address").val("");
        	}
		});
	});
	
	$(":checkbox").each(function(){
		if($(this).parent('.label_check').length==0){
				$(this).wrap('<label class="label_check"></label>');
		}
	});
	
	$(":radio").each(function(){
		if($(this).parent('.label_radio').length==0){
				$(this).wrap('<label class="label_radio"></label>')
		}
	});
	
	//老人会员详细信息中的兴趣爱好-------回显调用
	$(":input[name=hobby]").each(function() {
		if($("#hobby").val() != null && $("#hobby").val() != "" && $("#hobby").val() != undefined){
			var hobby1 = $(this).val();
			var hobby2 = $("#hobby").val()
			if(hobby2.indexOf(hobby1) != -1){
				$(this).attr("checked","checked");
			}
		}
	});
	
	//老人会员详细信息中的饮食禁忌-------回显调用
	$(":input[name=eat_taboo]").each(function() {
		if($("#eat_taboo").val() !=null && $("#eat_taboo").val() != "" && $("#eat_taboo").val() != undefined){
			var eat_taboo1 = $(this).val();
			var eat_taboo2 = $("#eat_taboo").val()
			if(eat_taboo2.indexOf(eat_taboo1) != -1){
				$(this).attr("checked","checked");
			}
		}
	});
	
	//老人会员详细信息中的照看人-------回显调用
	$(":input[name=take_care]").each(function() {
		if($("#take_care").val() !=null && $("#take_care").val() != "" && $("#take_care").val() != undefined){
			var take_care1 = $(this).val();
			var take_care2 = $("#take_care").val()
			if(take_care2.indexOf(take_care1) != -1){
				$(this).attr("checked","checked");
			}
		}
	});
	
	//老人会员详细信息中的健康状况-------回显调用
	$(":input[name=health_state]").each(function() {
		if($("#health_state").val() !=null && $("#health_state").val() != "" && $("#health_state").val() != undefined){
			var health_state1 = $(this).val();
			var health_state2 = $("#health_state").val()
			if(health_state2.indexOf(health_state1) != -1){
				$(this).attr("checked","checked");
			}
		}
	});
	
	//老人会员详细信息中的身体状况(单选)-------回显调用
	$(":input[name='body_state']").each(function() {
		if($("#body_state").val() !=null && $("#body_state").val() != "" && $("#body_state").val() != undefined){
			var body_state = $("#body_state").val();
			if($(this).val() == body_state){
				$(this).attr("checked","checked");
				if($(this).val()=='5'){
					$("#other_body_state").parent("label").show();
				}
			}
		}
	});
	
	setupLabel();
});